 
 function evl(filter,value)
    if(isempty(filter)) then
		evl=value
		exit function
	end if
		
	if IsNumeric(value) then
		value= eval(Replace(filter,"$",value))
	else
		value= eval(Replace(filter,"$", Chr(34) &value& Chr(34) ))
	end if 
	evl=value
end function

 Function readconf(filename)
	Dim ExcelApp,ExcelBook
	Dim oArrayList
    Set oArrayList = CreateObject( "System.Collections.ArrayList" )

	Set ExcelApp = CreateObject( "Excel.Application" )
	Set ExcelBook= ExcelApp.Workbooks.Open(FileName)
	ExcelBook.Application.Visible = False
	dim ni,rowcount
	

	For i=1 To ExcelBook.Sheets.count
		set sheet= ExcelBook.Sheets(i)
			'msgbox sheet.name
		LastRow = sheet.UsedRange.Rows.Count
		dim book1,sheet1,book2,sheet2
			'msgbox LastRow
		for r=2 to LastRow		
			set d2=new d2d
			d2.valid = sheet.cells(r,11).value		
			if d2.valid=1 or  d2.valid ="1" then
				d2.book1=sheet.cells(r,1).value	
				if isempty(d2.book1) then
					d2.book1=book1
				else
					book1=d2.book1
				end if		
				d2.sheet1 =sheet.cells(r,2).value	
				if isempty(d2.sheet1) then
					d2.sheet1=sheet1
				else
					sheet1=d2.sheet1
				end if		
				d2.icol1 =sheet.cells(r,3).value		
				d2.irow1 =sheet.cells(r,4).value	
				d2.book2 =sheet.cells(r,5).value		
				if isempty(d2.book2) then
					d2.book2=book2
				else
					book2=d2.book2
				end if	
				d2.sheet2 = sheet.cells(r,6).value		
				if isempty(d2.sheet2) then
					d2.sheet2=sheet2
				else
					sheet2=d2.sheet2
				end if	
				d2.icol2 =sheet.cells(r,7).value		
				d2.irow2 =sheet.cells(r,8).value		
				d2.filter =sheet.cells(r,9).value		
				d2.fans =sheet.cells(r,10).value		
				
				'WSH.Echo d2.book1
				if isempty(d2.irow1) or isempty(d2.irow2) then
					 Exit for
				end if
				oArrayList.add d2
			end if	
			'WSH.Echo ni&" : "& d2.toString
			
		next
		set sheet=nothing
	Next
	ExcelApp.Quit
	set ExcelBook=nothing
	set ExcelApp=nothing
	set readconf=oArrayList
	exit function
   
 end function 
 
 function distinctBook( ExcelApp,configlist)
	Dim Dic	, book

	Set Dic = CreateObject("Scripting.Dictionary")
	for i=0 to configlist.count-1
	
		set item=configlist.item(i)
		'msgbox item.book1
		if not Dic.Exists(item.book1) then			
			set book=ExcelApp.Workbooks.Open(item.book1)
			book.Application.Visible = False
			Dic.add item.book1,book
		end if
		if not Dic.Exists(item.book2) then
			set book=ExcelApp.Workbooks.Open(item.book2)
			book.Application.Visible = False
			Dic.add item.book2,book
		end if
	next
	'msgbox "distinctBook"
	set distinctBook=Dic

 end function 

 'config 中每行配置对应的 对象
class d2d
    public  book1,sheet1,irow1,icol1,book2,sheet2,irow2,icol2,filter,fans,valid
	Private Sub Class_Initialize()		
	End Sub
	public function toString
		toString=book1&","&sheet1&","&irow1&","&icol1&","&book2&","&sheet2&","&irow2&","&icol2&","&filter&","&fans&","&valid
	end function
	Private Sub Class_Terminate()	
		Set book1 = Nothing 
		Set sheet1 = Nothing 
		Set irow1 = Nothing 
		Set icol1 = Nothing 
		Set book2 = Nothing 
		Set sheet2 = Nothing 
		Set irow2 = Nothing 
		Set icol2 = Nothing 
		Set filter = Nothing 
		Set fans = Nothing 
		Set valid = Nothing 
	End Sub	
end class
